home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / sharewar / slunec / app / httrack.exe / {app} / src_win / WinHTTrack / Wid1.cpp < prev    next >
C/C++ Source or Header  |  2002-04-14  |  26KB  |  859 lines

  1. // Wid1.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <afxole.h>
  6. #include "oledlg.h"
  7. #include "afxodlgs.h"
  8.  
  9.  
  10. #include "Shell.h"
  11. #include "Wid1.h"
  12. //#include "filter.h"
  13.  
  14. #include "NewProj.h"
  15. #include "XSHBrowseForFolder.h"
  16.  
  17. #define HTS_WIN 1
  18. extern "C" {
  19.   #include "htslib.h"
  20. }
  21.  
  22. #include "about.h"
  23. //#include "ProxyId.h"
  24. #include "InsertUrl.h"
  25.  
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. extern CNewProj* dialog0;
  33.  
  34. extern int binput(char* buff,char* s,int max);
  35.  
  36. extern int check_continue(char* path_log);
  37. //extern HICON httrack_icon;
  38. extern int linput(FILE* fp,char* s,int max);
  39. extern int linput_trim(FILE* fp,char* s,int max);
  40. extern int linput_cpp(FILE* fp,char* s,int max);
  41. extern char* fconcat(char* a,char* b);
  42. extern int cmdl_opt(char* s);
  43. extern void Write_profile(CString path,int load_path);
  44. extern void Read_profile(CString path,int load_path);
  45. //extern int suivant4(void);
  46. extern CShellApp* CShellApp_app;
  47.  
  48. // Helper
  49. extern LaunchHelp* HtsHelper;
  50.  
  51. // reference sur objet
  52. extern Wid1* dialog1;
  53.  
  54. /* Main WizTab frame */
  55. #include "WizTab.h"
  56. extern CWizTab* this_CWizTab;
  57.  
  58. /* Main splitter frame */
  59. #include "DialogContainer.h"
  60. #include "splitter.h"
  61. extern CSplitterFrame* this_CSplitterFrame;
  62.  
  63. /* Back to FirstInfo */
  64. //#include "FirstInfo.h"
  65.  
  66. // pour lire ini qu'une fois
  67. int first_time=1;
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // Wid1 dialog
  71.  
  72.  
  73. /*class FileSelPath : public CFileDialog {
  74. public:
  75.   BOOL OnFileNameOK( ) { return 0; }
  76.   FileSelPath(BOOL a):CFileDialog(a) { };
  77. };*/
  78.  
  79. IMPLEMENT_DYNCREATE(Wid1, CPropertyPage)
  80.  
  81. //Cfilter filter;
  82. CString change(CString,char);
  83.  
  84. Wid1::Wid1()
  85.     : CPropertyPage(Wid1::IDD)
  86. {
  87.   dialog1=this;    /* NOTER REFERENCE */
  88.   cancel=0;
  89.     //{{AFX_DATA_INIT(Wid1)
  90.     m_C1 = -1;
  91.     m_urls = _T("");
  92.   m_todo = 0;
  93.     m_infomain = _T("");
  94.     m_filelist = _T("");
  95.     //}}AFX_DATA_INIT
  96. }
  97.  
  98. Wid1::~Wid1() {
  99.   dialog1=NULL;
  100. }
  101.  
  102. void Wid1::DoDataExchange(CDataExchange* pDX)
  103. {
  104.     CPropertyPage::DoDataExchange(pDX);
  105.     //{{AFX_DATA_MAP(Wid1)
  106.     DDX_Control(pDX, IDC_todo, m_ctl_todo);
  107.     DDX_Text(pDX, IDC_URL, m_urls);
  108.     DDX_CBIndex(pDX, IDC_todo, m_todo);
  109.     DDX_Text(pDX, IDC_INFOMAIN, m_infomain);
  110.     DDX_Text(pDX, IDC_filelist, m_filelist);
  111.     //}}AFX_DATA_MAP
  112. }
  113.  
  114. //IMPLEMENT_DYNAMIC(Wid1, CPropertyPage)
  115.  
  116. #define wm_CEasyDropTargetCallback (WM_USER + 1)
  117. BEGIN_MESSAGE_MAP(Wid1, CPropertyPage)
  118.     //{{AFX_MSG_MAP(Wid1)
  119.     ON_EN_CHANGE(IDC_URL, OnChangeUrl)
  120.     ON_CBN_SELCHANGE(IDC_todo, OnSelchangetodo)
  121.     ON_WM_CREATE()
  122.     ON_WM_HELPINFO()
  123.     ON_BN_CLICKED(ID_setopt, Onsetopt)
  124.     ON_BN_CLICKED(IDC_login2, Onlogin2)
  125.     ON_BN_CLICKED(IDC_br, Onbr)
  126.   ON_WM_DROPFILES()
  127.     ON_WM_DRAWITEM()
  128.     ON_WM_SHOWWINDOW()
  129.     ON_EN_CHANGE(IDC_filelist, OnChangefilelist)
  130.     //}}AFX_MSG_MAP
  131.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  132.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  133.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  134.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  135.   //
  136.   ON_BN_CLICKED(ID_LOAD_OPTIONS,OnLoadprofile)
  137.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,OnSaveprofile)
  138.     ON_BN_CLICKED(ID_LoadDefaultOptions, OnLoaddefault)
  139.     ON_BN_CLICKED(ID_SaveDefaultOptions, OnSavedefault)
  140.     ON_BN_CLICKED(ID_ClearDefaultOptions,OnResetdefault)
  141.     //ON_BN_CLICKED(ID_NewProjectImport, OnNewProject)
  142.     ON_BN_CLICKED(ID_SaveProject, OnSaveProject)
  143.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  144.   //
  145.   ON_MESSAGE( wm_CEasyDropTargetCallback, DragDropText)
  146. END_MESSAGE_MAP()
  147.  
  148. /////////////////////////////////////////////////////////////////////////////
  149. // Wid1 message handlers
  150.  
  151. BOOL Wid1::OnInitDialog( ) {
  152.   CPropertyPage::OnInitDialog();
  153.   EnableToolTips(true);     // TOOL TIPS
  154.  
  155.   // inits aprΦs affichage
  156.   url_status=-1;
  157.   filelist_status=-1;
  158.   //prox_status=-1;
  159.   log_flip=-1;
  160.   mir_status=-1;
  161.   proj_status=-1;
  162.   continue_status=-1;
  163.   OnChangeUrl();
  164.   OnChangefilelist();
  165.   //OnChangeprox();  // update disabled/normal
  166.   //OnSelchangedepth();  // update disabled/normal
  167.   OnSelchangetodo();
  168.  
  169.   // Patcher l'interface pour les Franτais ;-)
  170.   if (LANG_T(-1)) {    // Patcher en franτais
  171.     //SetDlgItemText(,"");
  172.     SetWindowText( LANG(LANG_G30)); // "Bienvenue dans WinHTTrack!");
  173.     SetDlgItemText(IDC_STATIC_action,LANG(LANG_G31)); // "Action:");
  174.     //SetDlgItemText(IDC_STATIC_filters,LANG(LANG_G33)); // "Filtres (refuser/accepter liens) :");
  175.     SetDlgItemText(IDC_STATIC_filters2,LANG(LANG_G41)); // "Options & prefs :");
  176.     SetDlgItemText(IDC_STATIC_paths,LANG(LANG_G34)); // "Chemins");
  177.     //SetDlgItemText(IDC_regdef,LANG(LANG_G37)); // "Sauver prΘfs");
  178.     //SetDlgItemText(IDOK,LANG(LANG_NEXT )); // "SUIVANT ->");
  179.     //SetDlgItemText(IDC_avant,LANG(LANG_BACK));
  180.     //SetDlgItemText(IDCANCEL,LANG(LANG_QUIT));  // exit 
  181.     //SetDlgItemText(IDfilter,LANG(LANG_G39)); // "DΘfinir..");
  182.     SetDlgItemText(ID_setopt,LANG(LANG_G40)); // "DΘfinir les options..");
  183.     //SetDlgItemText(IDC_mirtitle2,LANG(LANG_G42)); // "Nom du projet");
  184.     SetDlgItemText(IDC_login2,LANG_G43);
  185.     //SetDlgItemText(IDC_urls,LANG_G44);
  186.     SetDlgItemText(IDC_STATIC_webaddr,LANG_G44);
  187.     SetCombo(this,IDC_todo,LISTDEF_10);
  188.   }
  189.  
  190.   // inits
  191.   LAST_ACTION = m_ctl_todo.GetCount()-1;  // dernier item (update)
  192.  
  193.   // fichier ini
  194.   // lire default
  195.   if (first_time) {
  196.     first_time=0;
  197.  
  198.     //SetDlgItemText(IDC_INFOMAIN,"Please select an action, and fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below");
  199.  
  200.     /*
  201.     CString strSection       = "DefaultValues";    
  202.     CWinApp* pApp = AfxGetApp();
  203.     CString st;
  204.     int n;
  205.     */
  206.  
  207.     /*
  208.     if ((n = pApp->GetProfileInt(strSection, "Action",CB_ERR)) != CB_ERR)
  209.       m_ctl_todo.SetCurSel(n);
  210.  
  211.     if ((st = pApp->GetProfileString(strSection, "Depth")))
  212.       SetDlgItemText(IDC_depth,st);    
  213.     */
  214.  
  215.     /*
  216.     if ((st = pApp->GetProfileString(strSection, "MirrorPath","default")) != (CString) "default")
  217.       SetDlgItemText(IDC_pthmir,st);
  218.     if ((st = pApp->GetProfileString(strSection, "LogPath","default")) != (CString) "default")
  219.       SetDlgItemText(IDC_pathlog,st);
  220.     */
  221.  
  222.     // Infos la 1ere fois!
  223.     /*if (!pApp->GetProfileInt("Interface","FirstRun",0)) {
  224.       pApp->WriteProfileInt("Interface","FirstRun",1);
  225.       Onipabout();
  226.     }*/
  227.  
  228.   } else {
  229.     log_flip=0;
  230.   }
  231.   // fichier ini  
  232.  
  233.   //OnChangepathlog();  // update rΘpertoire log
  234.   //OnChangepthmir();  // update rΘpertoire miroir
  235.  
  236.   return TRUE;
  237. }
  238.  
  239. void Wid1::AfterInitDialog( ) {
  240.   WHTT_LOCATION("Wid1");
  241.   if (load_after_changes) {
  242.     AfterChangepathlog();
  243.     OnSelchangetodo();
  244.     load_after_changes=0;
  245.   }
  246.   OnChangeUrl();
  247.   OnChangefilelist();
  248. }
  249.  
  250. /*
  251. void Wid1::Onurls() {
  252.   CleanUrls();
  253. }
  254. */
  255.  
  256. // nettoyer les URLs
  257. void Wid1::CleanUrls() 
  258. {
  259.   CWaitCursor wait;
  260.   char* tempo, *ch,*str;
  261.   CString    st="";
  262.   // TODO: Add your control notification handler code here
  263.   
  264.   GetDlgItemText(IDC_URL,st);
  265.   tempo=(char*) malloc(st.GetLength()+1);
  266.   ch=(char*) malloc(st.GetLength()+1);
  267.   str=(char*) malloc(st.GetLength()*2+8192);
  268.   tempo[0]=ch[0]=str[0]='\0';
  269.   if ( (tempo) && (ch) && (str) ) {
  270.     strcpy(tempo,st);
  271.     int i;
  272.     for(i=0;i < (int) strlen(tempo);i++)  {
  273.       if(tempo[i]==10) tempo[i]=' ';
  274.       else if(tempo[i]==13) tempo[i]=' ';
  275.     }
  276.     
  277.     strcpy(ch,"");
  278.     int j=0;
  279.     for(i=0;i <= (int) strlen(tempo);i++) {
  280.       if ((tempo[i]==' ') || (tempo[i]==0)) {
  281.         ch[j++]='\0';
  282.         if ((strlen(ch)>0) && ((int) strlen(ch)<HTS_URLMAXSIZE) ) {
  283.           // vΘrifier URL
  284.           char adr[HTS_URLMAXSIZE*2],fil[HTS_URLMAXSIZE*2];
  285.           adr[0]=fil[0]='\0';
  286.           if (ident_url_absolute(ch,adr,fil)==-1) {
  287.             htsblk r;
  288.             char loc[HTS_URLMAXSIZE*2]; loc[0]='\0';    // Θventuelle nouvelle position
  289.             r=http_test(ch,fil,loc);
  290.             if ((r.statuscode==301) 
  291.               || (r.statuscode==302) 
  292.               || (r.statuscode==303) 
  293.               || (r.statuscode==307) 
  294.               || (r.statuscode==200)
  295.               ) {
  296.               strcpy(ch,loc);
  297.             }
  298.           }
  299.           
  300.           // recopier adresse
  301.           if (strstr(ch,":/")==NULL) {
  302.             strcat(str,"http://");
  303.           }
  304.           strcat(str,ch);
  305.           strcat(str,"\x0d\x0a");
  306.         }
  307.         j=0;
  308.       } else ch[j++]=tempo[i];
  309.     }
  310.     SetDlgItemText(IDC_URL,str);
  311.     free(tempo);
  312.     free(ch);
  313.     free(str);
  314.   } else
  315.     AfxMessageBox(LANG(LANG_DIAL10));
  316.   //m_urls=str;
  317. }
  318.  
  319. void Wid1::OnChangeUrl()
  320. {
  321.   CString st="";
  322.   //char tempo[8192];
  323.   char* tempo;
  324.     // TODO: If this is a RICHEDIT control, the control will not
  325.     // send this notification unless you override the CPropertyPage::OnInitDialog()
  326.     // function to send the EM_SETEVENTMASK message to the control
  327.   // with the ENM_CHANGE flag ORed into the lParam mask.
  328.   
  329.   // TODO: Add your control notification handler code here
  330.   GetDlgItemText(IDC_URL,st);
  331.   tempo=(char*) malloc(st.GetLength()+1);
  332.   if (tempo) {
  333.     strcpy(tempo,st);
  334.     int ex=0;
  335.     do {
  336.       if (strlen(tempo)>0) {
  337.         switch (tempo[strlen(tempo)-1]) {
  338.         case 10: case 13: case 32: tempo[strlen(tempo)-1]='\0';
  339.           break;
  340.         default: ex=1;
  341.           break;
  342.         }
  343.       } else ex=1;
  344.     } while(!ex);
  345.     
  346.     if ( ((strlen(tempo)>0) ) != url_status) { // || (m_ctl_todo.GetCurSel()==4)
  347.       url_status=!url_status;
  348.       
  349.       if (url_status) {
  350.         //m_ctl_next.ModifyStyle(WS_DISABLED,0);
  351.       }
  352.       else {
  353.         //m_ctl_next.ModifyStyle(0,WS_DISABLED);
  354.       }
  355.       //m_ctl_next.RedrawWindow();
  356.     }
  357.     free(tempo); tempo=NULL;
  358.   } else
  359.     AfxMessageBox(LANG(LANG_DIAL10));
  360. }
  361.  
  362. void Wid1::Refresh() {
  363.   OnChangeUrl();
  364.   //OnChangeprox();  // update disabled/normal
  365.   //OnSelchangedepth();  // update disabled/normal
  366. }
  367.  
  368. void Wid1::OnSelchangetodo() 
  369. {
  370.   int r;
  371.   r = m_ctl_todo.GetCurSel();
  372.   if (r!=CB_ERR) {
  373.     switch(r) {
  374.     case 0:
  375.       SetDlgItemText(IDC_INFOMAIN,
  376.       LANG(LANG_G2 /*"Mirror mode, fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  377.       "Mode miroir, remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  378.       );
  379.       break;
  380.     case 1:
  381.       SetDlgItemText(IDC_INFOMAIN,
  382.       LANG(LANG_G3 /* "Mirror mode with wizard (asks questions), fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  383.       "Mode miroir semi automatique (pose des questions), remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  384.       );
  385.       break;
  386.     case 2:
  387.       SetDlgItemText(IDC_INFOMAIN,
  388.       LANG(LANG_G4 /* "Get files mode, fill the addresse(s) of the files in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  389.       "Mode tΘlΘchargement de fichier, remplissez les addresse(s) des fichiers dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  390.       );
  391.       SetDlgItemText(IDC_depth,"");
  392.       break;
  393.     case 3:
  394.       SetDlgItemText(IDC_INFOMAIN,
  395.         LANG(LANG_G1B)
  396.         );
  397.       SetDlgItemText(IDC_depth,"");
  398.       break;
  399.     case 4:
  400.       SetDlgItemText(IDC_INFOMAIN,
  401.       LANG(LANG_G5 /* "Test links mode, fill the addresse(s) of the pages containing links to test in the URL box.\x0d\x0aThe log report will be saved in the location indicated below",
  402.       "Mode test de liens, remplissez les adresse(s) des pages contenant les liens α tester dans la liste d'URLs.\x0d\x0aLes fichiers d'audit seront sauvΘs α l'emplacement indiquΘ plus bas"*/)
  403.       );
  404.       SetDlgItemText(IDC_depth,"");
  405.       break;
  406.     default:
  407.       if (r == LAST_ACTION )
  408.         SetDlgItemText(IDC_INFOMAIN,
  409.         LANG(LANG_G6 /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  410.         "Mode mise α jour/continuer un miroir, vΘrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vΘrifiez les paramΦtres.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  411.         );
  412.       else if (r == LAST_ACTION-1 )
  413.         SetDlgItemText(IDC_INFOMAIN,
  414.         LANG(LANG_G6b /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  415.         "Mode mise α jour/continuer un miroir, vΘrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vΘrifiez les paramΦtres.\x0d\x0aLe mirroir sera sauvΘ α l'emplacement indiquΘ plus bas"*/)
  416.         );
  417.       break;
  418.     }
  419.     
  420.     if ( ((r==LAST_ACTION)||(r==LAST_ACTION-1)) != continue_status) {
  421.       continue_status=((r==LAST_ACTION)||(r==LAST_ACTION-1));
  422.       OnChangeUrl();
  423.     }
  424.   }
  425.   
  426. }
  427.  
  428.  
  429. void Wid1::OnChangepathlog() {
  430.   load_after_changes=1;
  431. }
  432.  
  433. void Wid1::AfterChangepathlog() 
  434. {
  435.   CString st="";
  436.   char tempo[8192];
  437.   BOOL modify;
  438.  
  439.   strcpy(tempo,dialog0->GetPath());
  440.   {
  441.     if (fexist(fconcat(tempo,"hts-cache/winprofile.ini"))) {    // un cache est prΘsent
  442.       if (fsize(fconcat(tempo,"hts-cache/winprofile.ini"))>0) {   // taille log contr⌠le>0
  443.         int i;
  444.         for(i=0;i<(int) strlen(tempo);i++)
  445.           if (tempo[i]=='/')
  446.             tempo[i]='\\';
  447.           Read_profile(fconcat(tempo,"hts-cache\\winprofile.ini"),0);
  448.  
  449.           // peut on modifier?
  450.           int pos=m_ctl_todo.GetCurSel();
  451.           if ((pos==LAST_ACTION) || (pos==LAST_ACTION-1) || (pos==0))
  452.             modify=true;
  453.           else
  454.             modify=false;
  455.           
  456.           // existe: update
  457.           if ((fexist(fconcat(tempo,"hts-cache/new.dat"))) && (fexist(fconcat(tempo,"hts-cache/new.ndx")))) {  // il existe dΘja un cache prΘcΘdent.. renommer
  458.             if (modify) {
  459.               if (
  460.                 (!fexist(fconcat(tempo,"hts-in_progress.lock")))
  461.                 &&
  462.                 (!fexist(fconcat(tempo,"hts-cache/interrupted.lock")))
  463.                 )
  464.                 m_ctl_todo.SetCurSel(LAST_ACTION);
  465.               else
  466.                 m_ctl_todo.SetCurSel(LAST_ACTION-1);
  467.             }
  468.             log_flip=1;
  469.           } else if (log_flip) {
  470.             if (modify)
  471.               m_ctl_todo.SetCurSel(0);
  472.             log_flip = 0;
  473.           }
  474.           OnSelchangetodo();
  475.       }
  476.     } else if (log_flip) {
  477.       m_ctl_todo.SetCurSel(0);
  478.       log_flip = 0;
  479.     }
  480.   }
  481. }
  482. /*
  483. void Wid1::OnClose() 
  484. {
  485.   // TODO: Add your message handler code here and/or call default
  486.   //Onfin();
  487.   //::OnClose();
  488.   if (AfxMessageBox(
  489.   LANG(LANG_J1)
  490.   ,MB_OKCANCEL)==IDOK) {
  491.     if (Save_current_profile(1)!=IDCANCEL) {
  492.       cancel=1;
  493.       CPropertyPage::OnCancel();
  494.     }
  495.   }
  496. }
  497. */
  498.  
  499.  
  500.  
  501. // ------------------------------------------------------------
  502. // TOOL TIPS
  503. //
  504. // ajouter dans le .cpp:
  505. // remplacer les deux Wid1:: par le nom de la classe::
  506. // dans la message map, ajouter
  507. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  508. // dans initdialog ajouter
  509. // EnableToolTips(true);     // TOOL TIPS
  510. //
  511. // ajouter dans le .h:
  512. // char* GetTip(int id);
  513. // et en generated message map
  514. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  515. BOOL Wid1::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  516. {
  517.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  518.   UINT nID =pNMHDR->idFrom;
  519.   if (pTTT->uFlags & TTF_IDISHWND)
  520.   {
  521.     // idFrom is actually the HWND of the tool
  522.     nID = ::GetDlgCtrlID((HWND)nID);
  523.     if(nID)
  524.     {
  525.       char* st=GetTip(nID);
  526.       if (st != "") {
  527.         pTTT->lpszText = st;
  528.         pTTT->hinst = AfxGetResourceHandle();
  529.         return(TRUE);
  530.       }
  531.     }
  532.   }
  533.   return(FALSE);
  534. }
  535. char* Wid1::GetTip(int ID)
  536. {
  537.   switch(ID) {
  538.     case IDC_todo:  return LANG(LANG_G9); break; // "Choose an action","Choisissez une action"); break; 
  539.     case IDC_depth: return LANG(LANG_G10); break; // "Maximum link depth to scan","Profondeur maximale"); break;
  540.     case IDC_URL:   return LANG(LANG_G11); break; // "Enter addresses here","Entrez les adresses ici"); break;
  541.     //case IDC_urls:  return LANG(LANG_G12); break; // "Check spelling","VΘrifier syntaxe"); break;
  542.     //case IDfilter:  return LANG(LANG_G13); break; // "Define additional filters","DΘfinir les filtres supplΘmentaires"); break;
  543.     //case IDC_pathlog:  return LANG(LANG_G16); break; // "Path","Chemin"); break;
  544.     //case IDC_br2:      return LANG(LANG_G17); break; // "Select path","Choix du chemin"); break;
  545.     //case IDC_pthmir:   return LANG(LANG_G18); break; // "Path","Chemin"); break;
  546.     //case IDC_br1:      return LANG(LANG_G19); break; // "Select path","Choix du chemin"); break;
  547.     case IDCANCEL:     return LANG(LANG_G20); break; // "Quit WinHTTrack","Quittter WinHTTrack"); break;
  548.     case IDC_ipabout:  return LANG(LANG_G21); break; // "About WinHTTrack","A propos de WinHTTrack"); break;
  549.     case IDC_regdef:   return LANG(LANG_G22); break; // "Save preferences as default values","Sauver les rΘglages par dΘfaut"); break;
  550.     case IDOK:         return LANG(LANG_G23); break; // "Click to continue","Clic pour continuer"); break;
  551.     case IDC_avant:     return LANG_TIPPREV; break;
  552.     case ID_setopt:    return LANG(LANG_G24); break; // "Click to define option","Clic pour dΘfinir les options"); break;
  553.     case IDC_login2:   return LANG_G24b; break;
  554.     case IDC_filelist: return LANG_G24c; break;
  555.     //case : return ""; break;
  556.   }
  557.   return "";
  558. }
  559. // TOOL TIPS
  560. // ------------------------------------------------------------
  561.  
  562.  
  563. /*
  564. void Wid1::OnDropFiles(HDROP hDropInfo) 
  565. {
  566.   int nf;
  567.   int i;
  568.   nf=DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);    // nbre de fichiers
  569.  
  570.   for(i=0;i<nf;i++) {
  571.     char* buff;
  572.     int size;
  573.     size=DragQueryFile(hDropInfo,i,NULL,0);    // taille buffer nΘcessaire
  574.     if (size>0) {
  575.       size+=16;    // marge de sΘcuritΘ
  576.       buff=(char*) calloc(size,1);
  577.       if (buff) {
  578.         if (DragQueryFile(hDropInfo,i,buff,size)>0) {    // ok copiΘ
  579.           AfxMessageBox(buff,MB_OKCANCEL+MB_ICONQUESTION);
  580.         }
  581.         free(buff);
  582.       }
  583.     }
  584.   }
  585.  
  586.   CPropertyPage::OnDropFiles(hDropInfo);
  587. }
  588. */
  589.  
  590. int Wid1::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  591. {
  592.     if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
  593.         return -1;
  594.  
  595.   // Drag&Drop
  596.   drag=new CEasyDropTarget(this);
  597.   if (drag->IsRegistered()) {
  598.     drag->SetTextCallback(wm_CEasyDropTargetCallback);
  599.   }
  600.     
  601.     return 0;
  602. }
  603.  
  604.  
  605. CString Wid1::TextToUrl(CString st,CLIPFORMAT cfFormat) {
  606.   // yop
  607.   // on va convertir les chaines α la suite
  608.   if (cfFormat==CF_TEXT) {
  609.     char *buff;
  610.     buff=(char*) malloc(st.GetLength()+2);
  611.     if (buff) {
  612.       char s[HTS_URLMAXSIZE*2];
  613.       CString res="";
  614.       strcpy(buff,st);
  615.       //
  616.       int ptr=0;
  617.       do {
  618.         ptr+=binput(buff+ptr,s,1000);
  619.         if (!strstr(s,"://")) {
  620.           char tempo[HTS_URLMAXSIZE*2]="http://";
  621.           strcat(tempo,s);
  622.           strcpy(s,tempo);
  623.         }
  624.         escape_check_url(s);
  625.         if (res.GetLength())
  626.           res+="\r\n";
  627.         res+=s;
  628.       } while(ptr<(int) strlen(buff));
  629.       st=res;
  630.       free(buff);
  631.     }
  632.   }
  633.   else if (cfFormat==CF_HDROP) {
  634.     if (st.GetLength()<256) {
  635.       char s[256];
  636.       strcpy(s,st);
  637.       escape_check_url(s);     // coder %
  638.       st="file://";
  639.       st+=s;
  640.     } else
  641.       st="";
  642.   }
  643.   else
  644.     st="";
  645.   return st;
  646. }
  647.  
  648. // Message from CEasyDropTarget
  649. LRESULT Wid1::DragDropText(WPARAM wParam,LPARAM lParam) {
  650.   if (lParam) {
  651.     CString st=*((CString*) lParam);
  652.     CLIPFORMAT cfFormat=wParam;
  653.     st=Wid1::TextToUrl(st,cfFormat);
  654.     if (st=="")
  655.       AfxMessageBox(LANG(LANG_DIAL11),MB_SYSTEMMODAL);
  656.     else
  657.       AddText(st);
  658.   }
  659.   return 0;
  660. }
  661.  
  662. // ajout d'URLs
  663. void Wid1::AddText(CString add_st) {
  664.   CString st;
  665.   GetDlgItemText(IDC_URL,st);
  666.   SetDlgItemText(IDC_URL,st+"\r\n"+add_st);
  667.   CleanUrls();
  668.   OnChangeUrl();
  669. }
  670.  
  671. // Appel aide
  672. BOOL Wid1::OnHelpInfo2() {
  673.   return OnHelpInfo(NULL);
  674. }
  675.  
  676. BOOL Wid1::OnHelpInfo(HELPINFO* dummy) 
  677. {
  678.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  679.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  680.   //LaunchHelp(pHelpInfo);
  681.   HtsHelper->Help("step2.html");
  682.   //HtsHelper->Help();
  683.   return true;
  684. }
  685.  
  686. void Wid1::OnLoadprofile() {
  687.   static char BASED_CODE szFilter[256];
  688.   strcpy(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RΘglages de WinHTTrack (*.opt)|*.opt||"*/));
  689.   CFileDialog* dial = new CFileDialog(true,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  690.   if (dial->DoModal() == IDOK) {
  691.     CString st=dial->GetPathName();
  692.     char s[256];
  693.     strcpy(s,st);
  694.     if (fexist(s))
  695.       Read_profile(st,1);
  696.     else
  697.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  698.   }
  699.   delete dial;
  700. }
  701.  
  702. void Wid1::OnSaveprofile() {
  703.   static char BASED_CODE szFilter[256];
  704.   strcpy(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RΘglages de WinHTTrack (*.opt)|*.opt||"*/));
  705.   CFileDialog* dial = new CFileDialog(false,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  706.   if (dial->DoModal() == IDOK) {
  707.     CString st=dial->GetPathName();
  708.     Write_profile(st,1);
  709.   }
  710.   delete dial;
  711. }
  712.  
  713. void Wid1::OnLoaddefault() {
  714.   if (AfxMessageBox(LANG(LANG_G27),MB_OKCANCEL)==IDOK) {
  715.     Read_profile("",0);
  716.   }
  717. }
  718.  
  719. void Wid1::OnSavedefault() {
  720.   if (AfxMessageBox(LANG(LANG_G28),MB_OKCANCEL)==IDOK) {
  721.     Write_profile("",0);
  722.   }
  723. }
  724.  
  725. void Wid1::OnResetdefault() {
  726.   if (AfxMessageBox(LANG(LANG_G29),MB_OKCANCEL)==IDOK) {
  727.     Read_profile("<null>",0);    // charger default
  728.     Write_profile("",0);         // et sauver
  729.   }
  730. }
  731.  
  732. /*
  733. void Wid1::OnNewProject() {
  734.   if (AfxMessageBox(LANG(LANG_G1C),MB_OKCANCEL)==IDOK) {
  735.     CWinApp* pApp = AfxGetApp();
  736.     CString name = pApp->m_pszHelpFilePath;
  737.     name=name.Left(name.GetLength()-4);
  738.     name += ".EXE";
  739.     ShellExecute(NULL,"open",name,"","",SW_RESTORE);
  740.     cancel=1;
  741.     EndDialog(1);
  742.   }
  743. }
  744. */
  745.  
  746. void Wid1::OnSaveProject() {
  747.   Save_current_profile(0);
  748. }
  749.  
  750. void Wid1::Onsetopt() 
  751. {
  752.   CShellApp_app->OptPannel();
  753. }
  754.  
  755. /*
  756. HCURSOR Wid1::OnQueryDragIcon() 
  757. {
  758.     // TODO: Add your message handler code here and/or call default
  759.     
  760.     return CPropertyPage::OnQueryDragIcon();
  761. }
  762. */
  763.  
  764. void Wid1::Onlogin2() 
  765. {
  766.   CInsertUrl url;
  767.   url.dest_path=dialog0->GetPath();
  768.   if (url.DoModal() == IDOK) {
  769.     if (url.m_urladr.Left(7)=="http://")
  770.       url.m_urladr=url.m_urladr.Mid(7);
  771.     CString st;
  772.     GetDlgItemText(IDC_URL,st);
  773.     if (url.m_urllogin.GetLength()==0) {
  774.       SetDlgItemText(IDC_URL,st+"\r\n"+url.m_urladr);
  775.     } else {
  776.       char *a,*b;
  777.       escape_in_url(a=copychar(LPCTSTR(url.m_urllogin)));
  778.       escape_in_url(b=copychar(LPCTSTR(url.m_urlpass)));
  779.       SetDlgItemText(IDC_URL,st+"\r\n"+(CString)(a)+":"+(CString)(b)+"@"+url.m_urladr);
  780.     }
  781.     CleanUrls();
  782.     OnChangeUrl();
  783.   }
  784. }
  785.  
  786. LRESULT Wid1::OnWizardNext() {
  787.   CString st;
  788.   UpdateData(TRUE);         // DoDataExchange
  789.   m_urls.TrimLeft(); m_urls.TrimRight();
  790.   m_filelist.TrimLeft(); m_filelist.TrimRight();
  791.   if ((m_urls.GetLength()>0) || (m_filelist.GetLength()>0)) {
  792.     if ((m_todo==LAST_ACTION)||(m_todo==LAST_ACTION-1)) {
  793.       char path[HTS_URLMAXSIZE*2];
  794.       CString st;
  795.       st=dialog0->GetPath();
  796.       strcpy(path,st);
  797.       if (check_continue(path))
  798.         return 0;
  799.       else {
  800.         GetDlgItem(IDC_URL)->SetFocus();
  801.         return -1;        // impossible de continuer
  802.       }
  803.     }
  804.   } else {
  805.     GetDlgItem(IDC_URL)->SetFocus();
  806.     return -1;
  807.   }
  808.   return 0;
  809. }
  810.  
  811. BOOL Wid1::OnSetActive( ) {
  812.   //OnInitDialog();
  813.   AfterInitDialog();
  814.   this_CWizTab->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
  815.   return 1;
  816. }
  817.  
  818. BOOL Wid1::OnQueryCancel( ) {
  819.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  820.   return 0;
  821. }
  822.  
  823. BOOL Wid1::OnKillActive( ) {
  824.   UpdateData(TRUE);         // DoDataExchange
  825.   return 1;
  826. }
  827.  
  828. void Wid1::Onbr() 
  829. {
  830.   static char BASED_CODE szFilter[256];
  831.   strcpy(szFilter,LANG(LANG_G25b));
  832.   CFileDialog* dial = new CFileDialog(true,"txt",NULL,OFN_HIDEREADONLY,szFilter);
  833.   if (dial->DoModal() == IDOK) {
  834.     if (fexist((char*)LPCSTR(dial->GetPathName()))) {
  835.       SetDlgItemText(IDC_filelist,dial->GetPathName());
  836.     } else {
  837.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  838.       SetDlgItemText(IDC_filelist,"");
  839.     }
  840.   }
  841.   delete dial;
  842.   OnChangefilelist();
  843. }
  844.  
  845. void Wid1::OnChangefilelist() 
  846. {
  847.   CString st;
  848.   GetDlgItemText(IDC_filelist,st);
  849.   if ((st.GetLength()>0) != filelist_status) {
  850.     filelist_status=(st.GetLength()>0);
  851.     if (filelist_status) {
  852.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(WS_DISABLED,0);
  853.     } else {
  854.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(0,WS_DISABLED);
  855.     }
  856.     GetDlgItem(IDC_STATIC_filelist)->RedrawWindow();
  857.   }
  858. }
  859.